Column {data-width=650}


Chart A

Column

Chart B

Chart C

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed # can show the code
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
library(rnoaa)

```

```{r}
weather_df = 
  rnoaa::meteo_pull_monitors(
    c("USW00094728", "USC00519397", "USS0023B17S"),
    var = c("DATE", "PRCP", "TMIN", "TMAX", "SNOW", "SNWD"), 
    date_min = "2017-01-01",
    date_max = "2017-12-31") %>%
  mutate(
    name = recode(
      id, 
      USW00094728 = "CentralPark_NY", 
      USC00519397 = "Waikiki_HA",
      USS0023B17S = "Waterhole_WA"),
    tmin = tmin / 10,
    tmax = tmax / 10,
    prcp = prcp / 10) %>%
  select(name, id, everything())
```

Column {data-width=650}

-----------------------------------------------------------------------

### Chart A

```{r}
weather_df %>% 
  mutate(text_label = str_c("Max:", tmax, "\nMin:", tmin)) %>% 
  plot_ly(x = ~tmax, y = ~tmin, text = ~text_label, alpha = .5, color = ~name, type = "scatter", mode = "markers", colors = "viridis")
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
weather_df %>% 
  mutate(name = fct_reorder(name, prcp),
         text_label = str_c(name, "\nPenetration: ", prcp, " mm")) %>% 
  plot_ly(y = ~prcp, x = ~name, color = ~name, text = ~text_label, type = "violin", colors = "viridis")
```

### Chart C

```{r}
weather_df %>% 
  plot_ly(x = ~date, y = ~tmax, color = ~name, type = "scatter", mode = "lines", colors = "viridis")
```